package be.itoffice.mbt.persist.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import be.itoffice.mbt.persist.entity.CalendarEvent;

@Service
@Transactional
public class CalendarEventDao {

	@PersistenceContext(unitName = "acme")
	EntityManager em;

	public void persistEvent(CalendarEvent event) {
		em.persist(event);
	}

	@SuppressWarnings("unchecked")
	public List<CalendarEvent> getAllEvents() {
		List<CalendarEvent> result = em.createQuery("select e from CalendarEvent e").getResultList();
		result.size(); // Hack for GAE with JPA
		return result;
	}

}
